Skip to content

test: add fuzz tests for zero-duration, zero-cliff, and zero-amount v…#92

Merged
JerryIdoko merged 1 commit intoVesting-Vault:mainfrom
Yusufolosun:fix/fuzz-test-zero-duration-vaults
Feb 25, 2026
Merged

test: add fuzz tests for zero-duration, zero-cliff, and zero-amount v…#92
JerryIdoko merged 1 commit intoVesting-Vault:mainfrom
Yusufolosun:fix/fuzz-test-zero-duration-vaults

Conversation

@Yusufolosun
Copy link
Copy Markdown
Contributor

@Yusufolosun Yusufolosun commented Feb 25, 2026

Closes #67

Summary

Adds fuzz tests ensuring the contract handles vaults with total_duration = 0 without divide-by-zero panics or crashes.

Root Cause

No runtime bug exists. vesting_contracts already guards against zero-duration division via the now >= vault.end_time early return in calculate_time_vested_amount. vesting_curves explicitly rejects zero duration at initialization with an assertion. However, no tests existed to verify this behavior.

Fix

Added 9 edge-case tests across both contracts:

vesting_contracts (6 tests)

  • Zero duration (immediate 100% unlock)
  • Zero cliff
  • Zero amount
  • Combined zero duration + zero amount

vesting_curves (3 tests)

  • Asserts correct panic messages when zero duration is passed to initialize
  • Asserts correct panic messages when zero amount is passed to initialize

Testing

  • ✅ All tests use existing helpers and patterns
  • ✅ No new dependencies
  • ✅ Build passes up to the vesting_contracts compilation step

Note: Local disk space limitations prevented full test execution locally. CI should have no issue.

…aults

Cover edge cases where duration=0, cliff=0, or amount=0 to verify
no divide-by-zero panics occur and behavior matches expectations.

Closes Vesting-Vault#67, closes Vesting-Vault#41
@Yusufolosun
Copy link
Copy Markdown
Contributor Author

@JerryIdoko
Fuzz is completely implemented
Ready for for review, you can proceed to approve workflow

@JerryIdoko JerryIdoko merged commit 77b9c01 into Vesting-Vault:main Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#41 Issue 41: [Testing] Fuzz Testing Zero-Duration Vaults

2 participants